//
//  CZOauthViewController.swift
//  wuJunQianWeiBo
//
//  Created by apple on 15/12/21.
//  Copyright © 2015年 wujunqian. All rights reserved.
//

import UIKit

class CZOauthViewController: UIViewController {

    override func loadView() {
        view = webView
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        //加载登录界面
        let url = CZNetWorkTool.shareInstance.oAuthURL()
        //请求
        let request = NSURLRequest(URL: url)
        webView.loadRequest(request)
        //设置导航栏
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "填充", style: UIBarButtonItemStyle.Plain, target: self, action: "didFillButton")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "取消", style: UIBarButtonItemStyle.Plain, target: self, action: "didCancelButton")
    }
    /**
     *  填充密码
     */
    func didFillButton()
    {
        //创建js代码
        let js = "document.getElementById('userId').value='czbkiosweibo@163.com'; document.getElementById('passwd').value='czbkios007';"
        //让webView来实现js代码
        webView.stringByEvaluatingJavaScriptFromString(js)
    }
    /**
     *  取消
     */
    func didCancelButton()
    {
        dismissViewControllerAnimated(true, completion: nil)
    }
    
    //MARK: - 懒加载
    private lazy var webView = UIWebView()
}
